/**
 * Copyright (c) 2024 Xiaoyangcc. All rights reserved.
 * <p>
 * This file is part of the ltc-cn-springboot project.
 * <p>
 * ltc-cn-springboot is distributed under the terms of the MIT License.
 * For details, see the accompanying LICENSE file or visit:
 * <a href="https://www.ltc-cn.top/project/ltc-cn-springboot">...</a>
 */
package top.ltc_cn.minecraft_manager.entity.minecraft;

import jakarta.persistence.*;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.UUID;

@Setter
@Getter
@Entity
@Table(name = "player_info")
public class PlayerInfo {

    @Id
    @Column(nullable = false, unique = true)
    private Long id;

    @Column(nullable = false, unique = true)
    @Size(min = 3, max = 16, message = "用户名长度必须在3到16个字符之间")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5A-Za-z0-9]+$", message = "用户名只能包含中文、字母、数字和下划线")
    private String playername;

    @Column(nullable = true)
    @Size(min = 2, max = 20, message = "昵称长度必须在2到20个字符之间")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5A-Za-z0-9]+$", message = "用户名只能包含中文、字母、数字和下划线")
    private String displayName;

    @Column(nullable = false, unique = true)
    @Size(min = 36, max = 128)
    private UUID uuid;

    @Column(nullable = false)
    private LocalDateTime regTime = LocalDateTime.now();

    // 构造函数
    public PlayerInfo() {}

    public PlayerInfo(Long id, String playername, String displayName, UUID uuid, LocalDateTime regTime) {
        this.id = id;
        this.playername = playername;
        this.displayName = displayName;
        this.uuid = uuid;
        this.regTime = regTime;
    }

}